<?php
include '../../init.php';

// 判断用户是否登录
is_login();
include DIR_CORE.'mysql.php';
$title = '沐水莲心-多选题';

//提取type表信息,填充类型字段
$sql = "select * from type";
$res = mysqli_query($link, $sql);
$tlist = array();
while ($row = mysqli_fetch_assoc($res)) {
    $tlist[] = $row;
}

//var_dump($tlist);


//提取single表总的数据信息
$sql = "select count(*) as sum from multiple";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_assoc($res);

//var_dump($row);

$rowCount = $row['sum'];

// 得到总记录数

if ($rowCount != 0) {
    $config =
    include DIR_CONFIG . 'config.php';
    $rowsPerPage = $config['page']['rowsPerPage'];
    $maxnum = $config['page']['maxnum'];
    $url = './multiple.php';
    
    //载入分页文件
    include DIR_CORE . 'page.php';

    $strPage = page($rowCount, $maxnum, $rowsPerPage, $url);

    $pageNum = isset($_GET['pageNum']) ? $_GET['pageNum'] : 1;

    //提取type表的数据
    $offset = ($pageNum - 1) * $rowsPerPage;
    $sql = "select * from multiple limit $offset, $rowsPerPage";
    $res = mysqli_query($link, $sql);
    // 得到资源结果集,
    
    //定义空数组存数据
    $list = array();
    //遍历数据库，取数据
    while ($row = mysqli_fetch_assoc($res)) {
        $list[]=$row;
    }
    //var_dump($list);
} else {
    $strPage = '<h3>信息量不够</h3>';
    echo $strPage;
}

include DIR_VIEW.'admin/multiple.html';
